<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Logic\MessageLogic;
use PHPUnit\Util\Json;


class MessageController extends Controller
{
    function __construct(Request $request)
    {
        $this->request = $request;
    }
    
    /**
     * 测试模型
     * 
     * @author 谢望鑫 <xiewxin@addcn.com>
     * 
     * @return JsonResponse
     */
    public function messageAll()
    {
        $param = $this->request->all();
        $messageLogic = new MessageLogic();
        $result=$messageLogic->messageAll($param);
        
        return response()->json($result);
    }
    
    /**
     * 留言板主页
     * 
     * @author 谢望鑫 <xiewxin@addcn.com>
     * 
     * @return JsonResponse
     */
    public function message()
    {
        return view('message.message');
    }
    
    
    /**
     * 留言列表
     * 
     * @author 谢望鑫 <xiewxin@addcn.com>
     * 
     * @return JsonResponse
     */
    public function messageList()
    {
        $param = $this->request->all();
        $messageLogic = new MessageLogic();
        $result = $messageLogic->messageList($param);
        
        return response()->json($result);
    }
    
    /**
     * 留言
     * 
     * @author 谢望鑫 <xiewxin@addcn.com>
     * 
     * @return JsonResponse
     */
    public function sendMsg()
    {
        $param = $this->request->all();
        $messageLogic = new MessageLogic();
        $result = $messageLogic->sendMsg($param);
        
        return response()->json($result);
    }
     
}